import six
from six.moves import builtins
_property = builtins.property
_tuple = builtins.tuple
from operator import itemgetter as _itemgetter
class TocCriteria(tuple):
    """Represents a particular way of organizing the documents in a
    repository, for the purpose of generating a table of contents for
    those douments.

    :param binding: The variable name (binding) for that same
                    predicate in the sparql results retrieved from the
                    query constructed by toc_query.
    :param label: A text label for the entire set of toc for this criteria.
    :param pagetitle: ...
    :param selector: a callable that groups documents (eg. first
                     letter, year-part of date, etc).
    :param key: a callable used for sorting documents
    """
    __slots__ = ()

    _fields = ('binding', 'label', 'pagetitle', 'selector', 'key')

    def __new__(_cls, binding, label, pagetitle, selector, key):
        'Create new instance of TocCriteria(binding, label, pagetitle, selector, key)'
        return _tuple.__new__(_cls, (binding, label, pagetitle, selector, key))

    @classmethod
    def _make(cls, iterable, new=tuple.__new__, len=len):
        'Make a new TocCriteria object from a sequence or iterable'
        result = new(cls, iterable)
        if len(result) != 4:
            raise TypeError('Expected 4 arguments, got %d' % len(result))
        return result

    def __repr__(self):
        'Return a nicely formatted representation string'
        return self.__class__.__name__ + '(binding=%r, label=%r, pagetitle=%r, selector=%r, key=%r)' % self

    def _asdict(self):
        'Return a new OrderedDict which maps field names to their values'
        return OrderedDict(zip(self._fields, self))

    __dict__ = property(_asdict)

    def _replace(_self, **kwds):
        'Return a new TocCriteria object replacing specified fields with new values'
        result = _self._make(map(kwds.pop, ('binding', 'label', 'pagetitle', 'selector','key'), _self))
        if kwds:
            raise ValueError('Got unexpected field names: %r' % list(kwds))
        return result

    def __getnewargs__(self):
        'Return self as a plain tuple.  Used by copy and pickle.'
        return tuple(self)

    binding = _property(_itemgetter(0), doc='Alias for field number 0')

    label = _property(_itemgetter(1), doc='Alias for field number 1')

    pagetitle = _property(_itemgetter(2), doc='Alias for field number 2')

    selector = _property(_itemgetter(3), doc='Alias for field number 3')

    key = _property(_itemgetter(4), doc='Alias for field number 4')
